home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7211 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  38 lines

  1. Newsgroups: comp.lang.c
  2. Path: prcc85.eng.prt.alcatel.pt!slspu2!news
  3. From: lve163d@slsufnt.stgl.sel.alcatel.de     (Oliver Boehm KS/ESF1 +49-711-821-47013)
  4. Subject: Re: Leap Years
  5. Message-ID: <DMrBBx.4pI@slspu2.stgl.sel.alcatel.de>
  6. Sender: news@slspu2.stgl.sel.alcatel.de
  7. Reply-To: OBoehm@stgl.sel.alcatel.de
  8. Organization: ALCATEL SEL Stuttgart
  9. References:  <8BA8405.02C70020E1.uuout@sourcebbs.com>
  10. Date: Wed, 14 Feb 1996 08:23:57 GMT
  11.  
  12.  
  13. In article <8BA8405.02C70020E1.uuout@sourcebbs.com>, david.mohorn@sourcebbs.com (DAVID MOHORN) writes:
  14. > Subject: Leap Years
  15. > Date: Sat, 10 Feb 96 17:09:00 -0500
  16. > Distribution: world
  17. > Reply-To: david.mohorn@sourcebbs.com (DAVID MOHORN)
  18. > X-Newsreader: PCBoard Version 15.22
  19. > X-Mailer: PCBoard/UUOUT Version 1.20
  20. > How do you feature out leap years?  If its evenly divisible by 400 and
  21. > 4?
  22.  
  23. years divisible by 100 are no leap years. Here two macros for that problem:
  24.  
  25. #define LEAP_YEARS(y)        (y) / 4 - (y) / 100 + (y) / 400
  26.                 /*  number of leap years since the year 0  */
  27. #define IS_LEAP_YEAR(y)        ((((y) % 4) == 0) && (((y) % 100) != 0)) || \
  28.                 ((((y) % 4) == 0) && (((y) % 400) == 0))
  29.  
  30. Regrads
  31. Oliver
  32. ------------------------------------------------v----------
  33. Oliver Boehm    OBoehm@stgl.sel.alcatel.de    | No RISC -
  34.                 boehm@ba-stuttgart.de        | No FUN
  35. ------------------------------------------------^----------
  36.  
  37.